package com.pony.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.amap.api.services.help.Tip;
import com.community.R;

public class BusPoiAdapter extends BaseAdapter {
	private Context mContext;
	private List<Tip> list_msg;

	public BusPoiAdapter(Context mContext, List<Tip> list_msg) {
		super();
		this.mContext = mContext;
		this.list_msg = list_msg;
	}

	@Override
	public int getCount() {
		return list_msg.size();
	}

	@Override
	public Object getItem(int position) {
		return list_msg.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder vh = null;
		String proName = null;

		if (convertView == null) {
			convertView = LayoutInflater.from(mContext).inflate(R.layout.bus_item_message, null);
			vh = new ViewHolder();
			vh.message_name = (TextView) convertView.findViewById(R.id.message_name);
			vh.message_msg = (TextView) convertView.findViewById(R.id.message_msg);
			convertView.setTag(vh);
		} else {
			vh = (ViewHolder) convertView.getTag();
		}
		try {

			Tip result = list_msg.get(position);
			vh.message_name.setText(result.getName());
			vh.message_msg.setText(result.getDistrict());
		} catch (Exception e) {
			// TODO: handle exception
		}
		
		
		return convertView;
	}

	class ViewHolder {
		TextView message_name;
		TextView message_msg;
	}

}
